/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import ru.jSkyRoom.bridge.ModBridge;
import ru.jSkyRoom.interfaces.JSkyMod;
import skyproc.GRUP_TYPE;
import skyproc.Mod;
import skyproc.ModListing;
import skyproc.SPGlobal;
import skyproc.SPImporter;
import skyproc.exceptions.BadMod;
import skyproc.exceptions.MissingMaster;

/**
 *
 * @author Rakev
 */
public class ModImporter {

    private static ModImporter instance = new ModImporter();

    public static ModImporter getInstance() {
        return instance;
    }

    private ModImporter() {
    }

    public void importMod(ModListing importingMod, GRUP_TYPE... grupTargets) throws BadMod, MissingMaster {
        SPImporter.importMod(importingMod, grupTargets);
    }

    public void importActiveMods(GRUP_TYPE... grupTargets) throws IOException, MissingMaster {
        SPImporter.importActiveMods(grupTargets);
    }

    public void importAllMods(GRUP_TYPE... grupTargets) throws IOException, MissingMaster {
        SPImporter.importAllMods(grupTargets);
    }

    public Collection<JSkyMod> getImportedMods() {
        Collection<JSkyMod> importedMods = new ArrayList();
        for (Mod mod : SPGlobal.getDB()) {
            importedMods.add(new ModBridge(mod));
        }
        return importedMods;
    }

    public JSkyMod getImportedModsComposite() {
        Collection<JSkyMod> importedMods = new ArrayList();
        for (Mod mod : SPGlobal.getDB()) {
            importedMods.add(new ModBridge(mod));
        }
        return new CompositeMod(importedMods);
    }
}
